class arrays {
	public static int[] fibonacci(int num) {
		int[] fib = new int [num];
		fib[0] = 0;
		fib[1] = 1;
		
		for (int i=2; i<fib.length;i++) {
			fib[i] = fib[i-1] + fib[i-2];
		}
			return fib;
	}
	public static int[] evenarray (int start, int stop) {
		int s = stop-start;
		int[] arr = new int [s+2];  
		int[] arry = new int [(s+2)/2];
		for (int j = 0; j<=s; j++) {
			arr[j] = start +j;
		}
		for (int i = 0; i<=s; i++) {
			if (arr[i] % 2 == 0){
				arry[i/2] = arr[i];
			}
		}
			return arry;
	}
	
	public static int[] oddarray (int start, int stop) {
		int s = stop-start;
		int[] arr = new int [s+2];  
		int[] arry = new int [(s+2)/2];
		for (int j = 0; j<=s; j++) {
			arr[j] = start +j;
		}
		for (int i = 0; i<=s; i++) {
			if (arr[i] % 2 != 0){
				arry[i/2] = arr[i];
			}
		}
			return arry;
	}
	
	public static int[] randomArray(int size) {
		int[] result = new int [size];
		for(int i=0;i<result.length;i++)
			result[i] = (int)(Math.random() * 100);
		return result;
	}
	
	
	public static char[] randomcharArray(int size) {
		char[] result = new char [size];
		for(int i=0;i<result.length;i++)
			result[i] = (char)(Math.random() * 200);
		return result;
	}

	public static int vowels(int size) {
		char[] arr = randomcharArray(size);
		printarray(arr);
		int vow = 0;
		for(int i=0; i<arr.length; i++){
			if ((arr[i] =='a' || arr[i] == 'A')||(arr[i] == 'e' || arr[i] == 'E')||(arr[i] == 'i' || arr[i] == 'I')||(arr[i] == 'o' || arr[i] == 'O')||(arr[i] == 'u' || arr[i] == 'U'))
			vow++;
		}
		return vow;
	}
		
	public static int[] reverseIntarray(int size) {
		int[] arr = randomArray(size);
		printarray(arr);
		int[] arry = new int [size];
		for(int i=0; i<arr.length; i++){
			arry[arr.length - i-1] = arr[i];
		}
		return arry;
	}
	
	public static int[][] randommultArray(int rows, int cols) {
		int[][] result = new int [rows][cols];
		for(int i=0;i<rows;i++){
			for(int j=0;j<cols;j++){
				result[i][j] = (int)(Math.random() * 100);
			}
		}
		return result;
	}
	
	public static int[][] matrixmult(int n) {
		int[][] arr = randommultArray(n,n);
		int[][] arry = randommultArray(n,n);
		printmultarray(arr);
		printmultarray(arry);
		int[][] product = new int [n][n];
		for(int i=0;i<n;i++)
			for(int j=0;j<n;j++){
				product[i][j] =0;
				for(int k=0; k<n; k++) {
					product[i][j] = product[i][j] + arr[i][k] * arry[k][j];
				}
			}
		return product;
	}
				
	
	public static int sumarray (int num) {
		int[] arr = randomArray(num);
		printarray(arr);
		System.out.println("arr gives" + arr);
		int sum=0;
			for(int i=0;i<arr.length;i++){
				sum = sum + arr[i];
			}
		System.out.println("sum of array is");
		return sum;
	}
	
	public static int largest (int num) {
		int[] arr = randomArray(num);
		printarray(arr);
		int large = 0;
			for(int i=0;i<arr.length;i++) {
				if (arr[i]>large)
					large=arr[i];
			}
		System.out.println("largest number is  ");
		return large;
	}
	
	public static int[][] multArray(int r, int c) {
		int[][] arr = {{1,3,4},{0,2,8}};
		 r=arr.length;
		 c=arr[0].length;
		System.out.println("r= "+r);
		System.out.println("c= "+c);
		return arr;
	}
	
	public static int sumMultarray(int r, int c) {
		int[][] arr = randommultArray(r,c);
		printmultarray(arr);
		int sum=0;
			for(int i=0;i<r;i++) {
				for(int j=0;j<c;j++) {
					sum = sum + arr[i][j];
				}
			}
		return sum;
	}
	
	public static int[][] addArrays(int r, int c) {
		int[][] arr = randommultArray(r,c);
		System.out.println("first matrix is ");
		printmultarray(arr);
		int[][] arry = randommultArray(r,c);
		System.out.println("second matrix is ");
		printmultarray(arry);
		int[][] sum = new int [r][c];
			for(int i=0; i<r; i++) {
				for(int j=0; j<c; j++) {
					sum[i][j]=arr[i][j] + arry[i][j];
				}
			}
		System.out.println("sum matrix is ");
		return sum;
	}
	
	public static void printarray(int[] res) {
		for (int i=0; i<res.length;i++)
			System.out.println(res[i]);//test
	}
	
	public static void printarray(double[] res) {
		for (int i=0; i<res.length;i++)
			System.out.println(res[i]);//test
	}
	
	public static void printarray(char[] res) {
		for (int i=0; i<res.length;i++)
			System.out.println(res[i]);//test
	}
	
	public static void printmultarray(int[][] res) {
		for (int i=0; i<res.length;i++) {
			for ( int j=0; j<res[0].length;j++) {
				System.out.println(res[i][j]);//test
			}
		}
	}
}
	